for (let i = 1; i <= 10; i++) {
    console.log(i)
}

let str = ''
for (n = 10; n >= 1; n--) {
    str += `${n.toString().padStart(3, '0')} `
}
console.log(str)

let aa = [1, 2, 3]
for (let i = 0; i < aa.length; i++) {
    console.log(aa[i])
}
for (let i = aa.length - 1; i >= 0; i--) {
    console.log(aa[i])
}
//循环数组下标
for (let i in aa) {
    console.log(i, aa[i])
}

//循环数组
for (let i of aa) {
    console.log(i)
}

let cc = {id: 100, name: '李四', addr: '郑州市'}
console.log(cc.name)
//遍历对象的属性集合，不能直接使用of
for (let k in cc) {
    console.log(cc[k])
}
console.log("*".repeat(50))
for (let k of Object.keys(cc)) {
    console.log(k)
    console.log(cc[k])
}
console.log("*".repeat(50))

//遍历对象的值集合
for (let v of Object.values(cc)) {
    console.log(v)
}

for (let i in 'helloworld') {
    console.log(i, 'helloworld'.charAt(i), 'helloworld'[i])
}

